package cn.ekuma.epos.analysis.front.ticket.model;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;
import cn.ekuma.epos.businesslogic.OrderUtil;
import com.openbravo.bean.sales.TicketsInfo;
import com.openbravo.format.Formats;

import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.util.IntegerUtils;
import com.openbravo.pos.util.RoundUtils;

public class TicketTableModel extends AbstractDTOTableModel<TicketsInfo>{

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		TicketsInfo obj=this.getObj(rowIndex);
		 switch(columnIndex){
         case 0:
             return obj.getLocation();
         case 1:
             return obj.getHostName();
         case 2:
             return obj.getTicketType()==0?OrderUtil.ORDERTYPE_Normal:OrderUtil.ORDERTYPE_Revoerse;
         case 3:
             return obj.getTicketId();
         case 4:
             return Formats.TIMESTAMP.formatValue(obj.getDate());
         case 5:
             return obj.getName();    
         case 6:
             return obj.getCustomer();
         case 7:
              return Formats.PERCENT.formatValue(obj.getM_dPriceRate());
         case 8:
              return RoundUtils.round(obj.getTotalPrice());
         case 9:
               return RoundUtils.round(obj.getTotalTax());
         case 10:
               return RoundUtils.round(obj.getTotalConsultCost());
     }
     return null;
 }
	
	private static int[] doubleInt={7,8,9};
	
	@Override
	public Class<?> getColumnClass(int columnIndex) {
		if(IntegerUtils.concat(columnIndex, doubleInt))
			return Double.class;
		return super.getColumnClass(columnIndex);
	}



	@Override
	public String[] getColumnNames() {
		
		return new String[]{
				AppLocal.getIntString("label.location"),
				AppLocal.getIntString("label.hostName"),
				AppLocal.getIntString("label.ordertype"),
				AppLocal.getIntString("label.orderid"),
				AppLocal.getIntString("label.date"),
				AppLocal.getIntString("Menu.Users"),
				AppLocal.getIntString("label.customer"),
				AppLocal.getIntString("label.priceRate"),
				AppLocal.getIntString("label.statePanel_totalPrice"),
				AppLocal.getIntString("label.statePanel_totalTaxPrice"),
				AppLocal.getIntString("label.consultCost")
            };
	}
	
	
}
